package com.shizhanzhe.qdd.home.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.Html;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.shizhanzhe.qdd.R;

/**
 * Created by YJ on 2018/10/24.
 */
public class SignDialog extends Dialog {
    TextView tvTitle;
    TextView tvTrue;
    TextView tvMsg;
    ImageView ivHead;

    private SignListener mListener;

    public void setListener(SignListener listener) {
        mListener = listener;
    }

    public SignDialog(@NonNull Context context) {
        super(context, R.style.my_dialog_new);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (null != getWindow()) {
            WindowManager.LayoutParams lp = getWindow().getAttributes();
            lp.dimAmount = 0.5f;
            getWindow().setAttributes(lp);
        }
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        setContentView(R.layout.dialog_sign);
        tvTrue = findViewById(R.id.tv_true);
        tvTitle = findViewById(R.id.tv_title);
        tvMsg=findViewById(R.id.tv_msg);
        ivHead = findViewById(R.id.iv_head);
        tvTrue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mListener.checktrue();
            }
        });
        setCanceledOnTouchOutside(true);
    }
    //设置弹框内容
    public void showMsg(String msg){
        tvTitle.setText(msg);
    }
    public void showImg(int imgId){
        ivHead.setImageResource(imgId);
    }
    public void showTX(String title,String msg){
        tvTitle.setText(title);
        tvMsg.setText(Html.fromHtml(msg));
        tvTrue.setText("点击复制");
    }
    public interface SignListener{
        void checktrue();
    }
}
